import sys
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['Times New Roman']
plt.rcParams.update({"font.size":20})


def get_pps(filename):
    loss_time_list = []
    with open(filename, 'r') as f:
        for row in f:
            row = int(row) / 1000
            if row < 0:
                loss_time_list.append(-row)
    return loss_time_list

if __name__ == "__main__":
    file_name = sys.argv[1]

    loss_time_list = get_pps(file_name)
    print(loss_time_list)

    plt.figure(figsize=(6, 3))
    
    for loss_time in loss_time_list:
        plt.axvline(loss_time, color = 'r')
    
    plt.xlim(0,30)
    plt.xlabel('Time (s)')
    # plt.ylabel('')
    plt.grid()
    plt.tight_layout()
    py_file_name = __file__.split('/')[-1].split('.')[0]
    plt.savefig(f"{py_file_name}+{file_name}.png", bbox_inches='tight')
    plt.show()
